import ComponentBase from "../../ComponentBase";
import { JhaoScrollViewItemAppear } from "./JhaoScrollViewLayout";

const { ccclass, property, menu } = cc._decorator;

@ccclass
@menu("JhaoScrollView/JhaoScrollViewItem")
export default class JhaoScrollViewItem extends ComponentBase {

    public index: number = 0;


    public playShowAnim(type: JhaoScrollViewItemAppear, sortIndex: number) {
        if (type == JhaoScrollViewItemAppear.FADE) {
            const element = this.node
            cc.tween(element)
                .by(0.01, { y: -100 })
                .delay(sortIndex * 0.05)
                .by(0.2, { opacity: 255, y: 100 })
                .start();
        }
        else if (type == JhaoScrollViewItemAppear.SCALE) {
            const element = this.node
            cc.tween(element)
                .delay(sortIndex * 0.05)
                .to(0.01, { scale: 0 })
                .to(0.2, { opacity: 255, scale: 1 })
                .start();
        }
    }

}